import java.util.Scanner;

public class demo01 {
    public static void main(String[] args) {
        //旋转
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int m=sc.nextInt();
        int[][] arr=new int[n][m];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                arr[i][j]=sc.nextInt();
            }
        }
        int[][] arr1=new int[m][n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                arr1[j][i]=arr[i][j];
            }
        }
        for (int i = 0; i < m; i++) {
            for (int j = n-1; j >= 0; j--) {
                System.out.print(arr1[i][j]+" ");
            }
            System.out.println();
        }
    }
}
